package de.lighti.starcraft.network;

import java.io.Serializable;

public class Message implements Serializable {
    public enum MESSAGE_TYPE {
        READY, BUSY, REQUEST_BINARY_CONTENT, PLAY, RESULT, QUIT
    }

    private static final long serialVersionUID = 1382596469698597877L;
    private final MESSAGE_TYPE type;
    private final Serializable payload;

    public Message( MESSAGE_TYPE type ) {
        this( type, null );
    }

    public Message( MESSAGE_TYPE type, Serializable payload ) {
        super();
        this.type = type;
        this.payload = payload;
    }

    public Serializable getPayload() {
        return payload;
    }

    public MESSAGE_TYPE getType() {
        return type;
    }

    @Override
    public String toString() {
        return "Message [type=" + type + ", payload=" + (payload != null ? payload.getClass().getName() : "<null>") + "]";
    }

}
